
from django.db import connections


def ensure_connection_exist():
    for conn in connections.all():
        # print(conn.connection)
        if not conn.connection or not conn.is_usable():
            # 有时候, celery重启之后， conn.connection 为空， 这里避免这个错误
            conn.connect()
